1
|
|
|
(function($) { |
|
|
|
|
2
|
|
|
|
3
|
|
|
var entityMap = { |
4
|
|
|
'&': '&', |
|
|
|
|
5
|
|
|
'<': '<', |
|
|
|
|
6
|
|
|
'>': '>', |
|
|
|
|
7
|
|
|
'"': '"', |
|
|
|
|
8
|
|
|
"'": ''', |
|
|
|
|
9
|
|
|
'/': '/', |
|
|
|
|
10
|
|
|
'`': '`', |
|
|
|
|
11
|
|
|
'=': '=' |
|
|
|
|
12
|
|
|
}; |
13
|
|
|
|
14
|
|
|
function escapeHtml(string) { |
15
|
|
|
return String(string).replace(/[&<>"'`=\/]/g, function (s) { |
|
|
|
|
16
|
|
|
return entityMap[s]; |
|
|
|
|
17
|
|
|
}); |
|
|
|
|
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
function podlove_init_color_buttons() { |
21
|
|
|
jQuery(document).ready( function($) { |
|
|
|
|
22
|
|
|
var params = { |
23
|
|
|
change: function(e, ui) { |
24
|
|
|
$( e.target ).val( ui.color.toString() ); |
25
|
|
|
$( e.target ).trigger('change'); // enable widget "Save" button |
|
|
|
|
26
|
|
|
}, |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
$('.podlove_subscribe_button_color').not('[id*="__i__"]').wpColorPicker( params ); |
|
|
|
|
30
|
|
|
}) |
|
|
|
|
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
$( document ).ready( function() { |
|
|
|
|
34
|
|
|
|
35
|
|
|
$("#Podlove_cover_image_select").on( 'click', function(event) { |
|
|
|
|
36
|
|
|
podlove_cover_image_selector = wp.media.frames.customHeader = wp.media( { |
|
|
|
|
37
|
|
|
title: i18n.media_library, |
|
|
|
|
38
|
|
|
library: { |
39
|
|
|
type: 'image' |
40
|
|
|
}, |
41
|
|
|
button: { |
42
|
|
|
text: i18n.use_for |
43
|
|
|
}, |
44
|
|
|
multiple: false |
45
|
|
|
} ); |
|
|
|
|
46
|
|
|
podlove_cover_image_selector.open(); |
47
|
|
|
|
48
|
|
|
podlove_cover_image_selector.on('select', function() { |
|
|
|
|
49
|
|
|
var podcast_image_url = podlove_cover_image_selector.state().get('selection').first().toJSON().url; |
|
|
|
|
50
|
|
|
$("#podlove-button-cover").val(podcast_image_url); |
|
|
|
|
51
|
|
|
$("#podlove-button-cover").trigger('change'); |
|
|
|
|
52
|
|
|
}); |
|
|
|
|
53
|
|
|
} ); |
|
|
|
|
54
|
|
|
|
55
|
|
|
$(document).ready(function () { |
|
|
|
|
56
|
|
|
podlove_init_color_buttons(); |
57
|
|
|
|
58
|
|
|
jQuery(document).on('widget-updated', podlove_init_color_buttons); |
|
|
|
|
59
|
|
|
jQuery(document).on('widget-added', podlove_init_color_buttons); |
|
|
|
|
60
|
|
|
|
61
|
|
|
// re-init after saving configs |
|
|
|
|
62
|
|
|
jQuery(document).on('ajaxComplete', function(e){ |
|
|
|
|
63
|
|
|
podlove_init_color_buttons(); |
64
|
|
|
}); |
|
|
|
|
65
|
|
|
}) |
|
|
|
|
66
|
|
|
|
67
|
|
|
var feed_counter = 0; |
68
|
|
|
var source = $("#feed_line_template").html(); |
|
|
|
|
69
|
|
|
|
70
|
|
|
$(".add_feed").on( 'click', function () { |
|
|
|
|
71
|
|
|
add_new_feed(); |
72
|
|
|
} ); |
|
|
|
|
73
|
|
|
|
74
|
|
|
if ( window.feeds !== undefined ) { |
75
|
|
|
$.each( feeds, function (index, feed) { |
|
|
|
|
76
|
|
|
add_existing_feed(feed); |
|
|
|
|
77
|
|
|
} ); |
|
|
|
|
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
function add_new_feed() { |
81
|
|
|
row = source.replace( /\{\{url\}\}/g, '' ); |
|
|
|
|
82
|
|
|
row = row.replace( /\{\{itunesfeedid\}\}/g, '' ); |
83
|
|
|
row = row.replace( /\{\{id\}\}/g, feed_counter ); |
84
|
|
|
|
85
|
|
|
$("#feeds_table_body").append(row); |
|
|
|
|
86
|
|
|
|
87
|
|
|
new_row = $("#feeds_table_body tr:last"); |
|
|
|
|
88
|
|
|
new_row.find("input:first").focus(); |
|
|
|
|
89
|
|
|
|
90
|
|
|
$(".podlove-icon-remove").on( 'click', function () { |
|
|
|
|
91
|
|
|
$(this).closest("tr").remove(); |
|
|
|
|
92
|
|
|
} ); |
|
|
|
|
93
|
|
|
|
94
|
|
|
feed_counter++; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
function add_existing_feed( feed ) { |
98
|
|
|
row = source.replace( /\{\{url\}\}/g, escapeHtml(feed.url) ); |
|
|
|
|
99
|
|
|
row = row.replace( /\{\{id\}\}/g, feed_counter ); |
100
|
|
|
if ( feed.itunesfeedid == null ) { |
|
|
|
|
101
|
|
|
row = row.replace( /\{\{itunesfeedid\}\}/g, '' ); |
102
|
|
|
} else { |
103
|
|
|
row = row.replace( /\{\{itunesfeedid\}\}/g, escapeHtml(feed.itunesfeedid) ); |
|
|
|
|
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
$("#feeds_table_body").append(row); |
|
|
|
|
107
|
|
|
|
108
|
|
|
new_row = $("#feeds_table_body tr:last"); |
|
|
|
|
109
|
|
|
new_row.find('select.podlove-media-format option[value="' + escapeHtml(feed.format) + '"]').attr('selected',true); |
|
|
|
|
110
|
|
|
|
111
|
|
|
$(".podlove-icon-remove").on( 'click', function () { |
|
|
|
|
112
|
|
|
$(this).closest("tr").remove(); |
|
|
|
|
113
|
|
|
} ); |
|
|
|
|
114
|
|
|
|
115
|
|
|
feed_counter++; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
} ); |
|
|
|
|
119
|
|
|
}(jQuery)); |